﻿using Prism.Commands;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WPF.Project.Demo.Common.Models;

namespace WPF.Project.Demo.ViewModels
{
    class IndexViewModel : BindableBase
    {

        private readonly IDialogService dialog;
        public IndexViewModel(IDialogService dialog)
        {
            this.dialog = dialog;
            TaskBars = new ObservableCollection<TaskBar>();
            CreateTaskBar();


            ExecuteCommand = new DelegateCommand<string>(Execute);

        }

        private void Execute(string obj)
        {
            switch (obj)
            {
                case "AddToDo":
                    AddToDo();
                    break;
                case "AddMemo":
                    AddMemo();
                    break;
            }
        }

        void AddToDo()
        {
            dialog.ShowDialog("AddToDoView");
        }

        void AddMemo()
        {
            dialog.ShowDialog("AddMemoView");
        }


        public DelegateCommand<string> ExecuteCommand { get; private set; }

        ObservableCollection<TaskBar> taskBars;
        public ObservableCollection<TaskBar> TaskBars
        {
            get { return taskBars; }
            set { taskBars = value; RaisePropertyChanged(); }
        }

        ObservableCollection<ToDoDto> toDoDtos;
        public ObservableCollection<ToDoDto> ToDoDtos
        {
            get { return toDoDtos; }
            set { toDoDtos = value; RaisePropertyChanged(); }
        }


        ObservableCollection<MemoDto> memoDtos;
        public ObservableCollection<MemoDto> MemoDtos
        {
            get { return memoDtos; }
            set { memoDtos = value; RaisePropertyChanged(); }
        }

        void CreateTaskBar()
        {
            TaskBars.Add(new TaskBar { Icon = "ColckFast", Title = "汇总", Content = "12", Color = "#FF0CA0FF", Target = "" });
            TaskBars.Add(new TaskBar { Icon = "ClockCheckOutline", Title = "已完成", Content = "12", Color = "#FF1ECA3A", Target = "" });
            TaskBars.Add(new TaskBar { Icon = "CharLinrVariant", Title = "完成比例", Content = "100%", Color = "#FF02C6DC", Target = "" });
            TaskBars.Add(new TaskBar { Icon = "PlaylistStar", Title = "备忘录", Content = "10", Color = "#FFFFA000", Target = "" });
        }



    }
}
